package com.sxbbc.common.core.enums.redis;

/**
 * redis 设置会过期的建，监听过期做不同处理,键名作为搜字母拼接唯一主键
 * 此枚举类均为 表示存在有效期的redis键名
 * 如果设置时间为0表示当前键名对应有效期是动态
 * @author arno
 *
 */
public enum RedisExpiredEnums {
	
	ORDER_SETTLE_BUY("ordersettlebuy_","订单购买去结算生成订单仅作为显示，键名规则为ordersettlebuy_订单号",300),
	ORDER_BUY("orderbuy_","订单购买预生成订单，并处理库存，键名规则为orderbuy_订单号",1800),
	WX_WEB_TOKEN("wxwebtoken","微信网页临时token，键名规则为wxwebtoken",3600),
	WX_PROGRAM_TOKEN("wxprogramtoken","微信小程序临时token，键名规则为wxprogramtoken",3600),
	GROUP_ORDER("grouporder_","开团成功生成订单,给加入拼团和拼团失败退款使用,规则grouporder_拼团编号",0),
	GROUP_NUM("groupnum_","开团成功生成记录当前团购拼团人数,规则groupnum_拼团编号",0),
	SECKILL_PRO("seckillpro_","秒杀商品过期检测",0),
	SECKILL_WILL_PRO("seckillwillpro_","设置即将开始的秒杀活动序列",0),
	WX_JSAPI_TICKET("wxjsapiticket", "微信JS接口的临时票据，键名规则为wxjsapiticket", 3600);

	/** 键名前缀 */
	private String key;
	/** 描述 */
	private String remark;
	/** 单位秒 表示当前键名存活时间 */
	private long second;
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public long getSecond() {
		return second;
	}
	public void setSecond(long second) {
		this.second = second;
	}
	
	private RedisExpiredEnums(String key,String remark,long second) {
		this.key=key;
		this.remark=remark;
		this.second=second;
	}
	
	public static RedisExpiredEnums getEnums(String key) {
		for(RedisExpiredEnums e:RedisExpiredEnums.values()) {
			if(e.getKey().equals(key)) {
				return e;
			}
		}
		return null;
	}
}
